<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" charset="utf-8">
        /**
         * 借助闭包创建单体
         * @type {{}}
         */
        var BHX = {};
        BHX.Singleton  = (
            function () {
                var a1 = true;
                var a2 = 10;
                var f1 = function () {
                    alert('f1');
                }
                var f2 = function () {
                    alert('f2');
                }
                return {
                    attr1:a1,
                    attr2:a1,
                    method1:function () {
                        f1();
                    },
                    method2:function () {
                        f2();
                    }
                }
            }
        )()
    </script>
</head>
<body>
</body>
</html>